#ifndef CAMHANDLER_H
#define CAMHANDLER_H

#include <osgGA/GUIEventHandler>
#include <osg/Camera>
#include <osg/Vec3d>
#include "Clip.h"
#include "Moveenums.h"
#include "Hud.h"
#include "Keyfuncmap.h"

class CamHandler : public osgGA::GUIEventHandler{
public:
	CamHandler(osg::Camera* cam, Clip* clip, HUD* hud, osg::Vec3d eye,
		osg::Vec3d center, osg::Vec3d up);
	~CamHandler();

	bool handle(const osgGA::GUIEventAdapter &ea, 
		osgGA::GUIActionAdapter &aa);

	OpenThreads::Mutex  * getLockMutex();

	void incAz();
	void decAz();
	void incPo();
	void decPo();
	void stepLeft();
	void stepRight();
	void stepForward();
	void stepBackward();
	void lookUp();
	void lookDown();
	void lookLeft();
	void lookRight();
	void stepUp();
	void stepDown();
	void resetCenter();
	void clipSwitch();

private:
	bool newKeyDownEvent, newKeyUpEvent;
	volatile bool locked;

	MOVEACTION m;
	keyFunctionMap::iterator itr;
	OpenThreads::Mutex lockmutexC;

	// Eine Map fuer die Key-DOWN Funktionen
	keyFunctionMap keyFuncMap;

	// Eine Map fuer die Key-UP Funktionen
	keyFunctionMap keyUPFuncMap;
    osg::observer_ptr<osg::Camera> _cam;
    Clip * _clip;
    HUD * _hud;
	osg::Vec3d _eye, _center, _up, _deltaEye, _deltaCenter, _newPos;


	int azimut, pol;
	double step;

	void printCoords(const char key);
	void keyToHandle(const int k, const MOVEACTION a);
	void updateCam();

};

#endif
